<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

<div class="content">
    <header>
        <h1>Course Settings</h1>
        <div class="btn-wrapper">
            <a href="{{ theme_url }}" class="btn btn-default">Customize Website Theme</a>
        </div>
    </header>
    <div id="config">
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />

        <h2>Course Info</h2>
        <hr>

        <label for="course-name" class="config-row">
            <div class="option-title">Full Course Name</div>
            <div class="option-alt">Input the course name that should appear in the header of the site (your course code is {{ core.getConfig().getCourse() }})</div>
        </label>
        <input class="config-row" type="text" name="course_name" id="course-name" value="{{ fields['course_name'] }}" />

        <label for="course-home-url" class="config-row">
            <div class="option-title">Course Home URL</div>
            <div class="option-alt">Input the url that will link to your course page from the Course Name</div>
        </label>
        <input class="config-row" type="text" name="course_home_url" id="course-home-url" value="{{ fields['course_home_url'] }}" />

        <div id="forum-enabled-wrapper" class="config-row checkbox-row">
            <input type="checkbox" name="forum_enabled" id="forum-enabled" value="true" {{ fields['forum_enabled'] ? 'checked': '' }} />
            <label for="forum-enabled">
                <div class="option-title">Enable Discussion Forum</div>
                <div class="option-alt">Choose whether to enable a forum for this course.</div>
                {% if categories_empty %}
                    <h4 id="forum-category-warning" class="red-message" {{ fields['forum_enabled'] ? '': 'hidden' }} >Categories must be created in order to use the Discussion Forum. Click the link below to add categories.</h4>
                    <a id="forum-enabled-message" href="{{ manage_categories_url }}" alt="Customize Categories" {{ fields['forum_enabled'] ? '': 'hidden' }} >Customize categories.</a>
                {% endif %}
            </label>
        </div>

        <div id="queue-enabled-wrapper" class="config-row checkbox-row">
            <input type="checkbox" name="queue_enabled" id="queue-enabled" value="true" {{ fields['queue_enabled'] ? 'checked': '' }} />
            <label for="queue-enabled">
                <div class="option-title">Enable Office Hours Queue</div>
                <div class="option-alt">Choose whether to enable an office hours queue for this course.</div>
            </label>
        </div>

        <h2>Submissions</h2>
        <hr>

        <label for="upload-message" class="config-row">
            <div class="option-title">Upload Message</div>
            <div class="option-alt">
                What is the message that should be shown to students above the upload area on the submission page.
            </div>
        </label>
        <textarea class="config-row" name="upload_message" id="upload-message">{{ fields['upload_message'] }}</textarea>

        <label for="private-repository" class="config-row">
            <div class="option-title">Course Autograding Config Directory</div>
            <div class="option-alt">
                Use your own directories for storing gradeable configs. Will appear in the create/edit gradeable page.
                To enter multiple directories, type the full paths separated by a comma.
                Leave blank if you do not have a private repository for gradeable configurations.
            </div>
        </label>
        <input class="config-row" type="text" name="private_repository" id="private-repository" value="{{ fields['private_repository'] }}" />

        <div class="config-row checkbox-row">
            <input type="checkbox" name="keep_previous_files" id="keep-previous-files" value="true" {{ fields['keep_previous_files'] ? 'checked' : '' }} />
            <label for="keep-previous-files">
                <div class="option-title">Keep previous files uploaded</div>
                <div class="option-alt">Should the files from previous submission be in the upload box by default.</div>
            </label>
        </div>

        <fieldset class="config-row">
            <legend>
                <div class="option-title">Version Control System (VCS) Type</div>
                <div class="option-alt">Choose the type of VCS if students are submitting via VCS repository.</div>
            </legend>
            <div id="vcs-options" class="option-input flex-row">
                <label for="vcs-type-git">
                    <input type="radio" name="vcs_type" id="vcs-type-git" value="git" {{ (fields['vcs_type'] == 'git') ? 'checked' : '' }}/>
                    Git
                </label>
                {#
                <input type="radio" name="vcs_type" value="svn" {{ (fields['vcs_type'] == 'svn') ? 'checked' : '' }}/> <label for="vcs_type_svn">SVN</label>
                <input type="radio" name="vcs_type" value="mer" {{ (fields['vcs_type'] == 'mer') ? 'checked' : '' }}/> <label for="vcs_type_mer">Mercurial</label>
                #}
            </div>
        </fieldset>

        <label for="vcs-base-url" class="config-row">
            <div class="option-title">Version Control System (VCS) Base URL</div>
            <div class="option-alt">
                Base URL if students are submitting via VCS repository.<br />
                external ex. <kbd>https://github.com/test-course</kbd><br />
                internal ex. <kbd>ssh+svn://192.168.56.101/test-course</kbd>
            </div>
        </label>
        <input class="config-row" type="text" name="vcs_base_url" id="vcs-base-url" value="{{ fields['vcs_base_url'] }}" />

        <h2>Late Days</h2>
        <hr>

        <label for="default-student-late-days" class="config-row">
            <div class="option-title">Initial Allowed Late Days (Per Student, Per Semester)</div>
            <div class="option-alt">
                Number of allowed late days given to each student when they are added to
                the course.  Additional late days can be granted (e.g., as incentives)
                using the "Late Days Allowed" form.
            </div>
        </label>
        <input class="config-row" type="number" name="default_student_late_days" id="default-student-late-days" value="{{ fields['default_student_late_days'] }}" />

        <label for="default-hw-late-days" class="config-row">
            <div class="option-title">Default Maximum Late Days Per Assignment</div>
            <div class="option-alt">
                Specify the default number of late days that may be used on a single homework.  This can be adjusted
                per assignment on the "Create/Edit Gradeable" form.
            </div>
        </label>
        <input class="config-row" type="number" name="default_hw_late_days" id="default-hw-late-days" value="{{ fields['default_hw_late_days'] }}" />

        <h2>Grading</h2>
        <hr>

        <label for="course-email" class="config-row">
            <div class="option-title">Grades Returned Message</div>
            <div class="option-alt">Input the message shown on grades returned to students.  Include instructions for grade inquiries and the course staff mailing list.</div>
        </label>
        <textarea class="config-row" name="course_email" id="course-email" />{{ fields['course_email'] }}</textarea>

        <div class="config-row checkbox-row">
            <input type="checkbox" name="regrade_enabled" id="regrade-enabled" value="true" {{ fields['regrade_enabled'] ? 'checked': '' }} />
            <label for="regrade-enabled">
                <div class="option-title">Grade Inquiries Allowed</div>
                <div class="option-alt">Allow students to submit grade inquiries for assignments.<br>
                Note: Grade inquiry dates and details configured per assignment.</div>
            </label>
        </div>

        <label for="regrade-message" class="config-row">
            <div class="option-title">Grade Inquiry Warning Message</div>
            <div class="option-alt">Input the warning message show to students while submitting a grade inquiry.</div>
        </label>
        <textarea class="config-row" name="regrade_message" id="regrade-message" rows="4"/>{{ fields['regrade_message'] }}</textarea>

        {# TODO: Not sure what this is
            <label for="zero_rubric_grades">
                <div class="option-title">Zero Rubric Grading</div>
                <div class="option-alt">Should each rubric item score default to zero?  If disabled, the grading rubric will
                    default at full credit.   Note: Assignments that are not submitted/submitted too late always be set to zero.</div>
            </label>
            <div class="option-input"><input type="checkbox" name="zero_rubric_grades" id="zero_rubric_grades" value="true" {{ fields['zero_rubric_grades'] ? 'checked' : '' }} /></div>
        #}

        <h2>Student Features</h2>
        <hr>

        <div class="config-row checkbox-row">
            <input type="checkbox" name="display_rainbow_grades_summary" id="display-rainbow-grades-summary" value="true" {{ fields['display_rainbow_grades_summary'] ? 'checked' : '' }} />
            <label for="display-rainbow-grades-summary">
                <div class="option-title">Display Rainbow Grades Summary</div>
                <div class="option-alt">
                    Show Rainbow Grades summaries to students.
                    <strong>Note:</strong>
                    <a target=_blank href="http://submitty.org/instructor/rainbow_grades/">
                    You must manually run rainbow grades. <i style="font-style:normal;" class="fa-question-circle"></i></a>
                </div>
            </label>
        </div>

        {# Only show the checkbox if the submitty-admin user is available and in the course as an instructor #}
        {% if submitty_admin_user['verified'] %}
            {% if submitty_admin_user['in_course'] %}
                <div class="config-row checkbox-row">
                    <input type="checkbox" name="auto_rainbow_grades" value="true" {{ fields['auto_rainbow_grades'] ? 'checked' : '' }} />
                    <label for="auto-rainbow-grades">
                        <div class="option-title">Automatic Nightly Processing for Rainbow Grades Generation</div>
                        <div class="option-alt">
                            With a valid customization.json Rainbow Grades configuration,<br>
                            a Submitty cron job will update Rainbow Grades every night at approximately 2am.
                        </div>
                    </label>
                </div>
            {% else %}
            <div class="option-title">Automatic Nightly Processing for Rainbow Grades Generation</div>
            <div class="option-alt">
                NOTE:  To facilitate automatic nightly cron processing of Rainbow Grades,<br>
                you must add the special user '{{ submitty_admin_user['user_id'] }}' to your course as an instructor user.<br><br>
            </div>
            {% endif %}
        {% else %}
        <div class="option-title">Automatic Nightly Processing for Rainbow Grades Generation</div>
        <div class="option-alt">
          NOTE:  This server is not configured to allow automatic nightly cron processing of Rainbow Grades.<br>
          Please ask your system administrator to configure this option on your server.<br><br>
        </div>
        {% endif %}
        <label for="room-seating-gradeable-id" class="config-row">
            <div class="option-title">Display Room Seating Guide</div>
            <div class="option-alt">Pick a gradeable for which seating will be shown to students. Select --None-- to hide seating guide.</div>
        </label>
        <div id="instructor-seating" class="config-row">
            <select name="room_seating_gradeable_id" id="room-seating-gradeable-id">
                {% for seating_option in gradeable_seating_options %}
                    <option value="{{ seating_option['g_id'] }}"{{ fields['room_seating_gradeable_id'] == seating_option['g_id'] ? ' selected' : ''}}>
                        {{ seating_option['g_title'] }} {{ seating_option['g_id'] != "" ? "<" ~ seating_option['g_id'] ~ ">" : "" }}
                    </option>
                {% endfor %}
            </select>
            <label id="seating-only-label" class="option-alt" for="seating-only-for-instructor">
                Visible only to Instructors?
                <input type="checkbox" name="seating_only_for_instructor" id="seating-only-for-instructor" value="true"{{ fields['seating_only_for_instructor'] ? 'checked' : '' }} />
            </label>
        </div>

        <div id="email-seating-assignment-label" class="option-desc option-title config-row">
            Customize an email to send to each students
            {% if not email_enabled %}
                <p class="yellow-message">Emails are disabled: contact your System Admin to enable emails</p>
            {% else %}
                <button id="email-seating-assignment" class="option-alt bare-button">
                    <a href="{{ email_room_seating_url }}" class="btn btn-primary">
                        Email Seating Assignments
                    </a>
                </button>
            {% endif %}
        </div>

        <div class="config-row checkbox-row">
            <input type="checkbox" name="display_custom_message" id="display-custom-message" value="true" {{ fields['display_custom_message'] ? 'checked' : '' }} />
            <label for="display-custom-message">
                <div class="option-title">Display Custom Message</div>
                <div class="option-alt">Show a custom message to students at the top of the navigation page.</div>
            </label>
        </div>
    </div>
</div>
